﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using PAT.Entities;
using PAT.Data;

#endregion

namespace PAT.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="PatConfiguracionTallerProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class PatConfiguracionTallerProviderBaseCore : EntityProviderBase<PAT.Entities.PatConfiguracionTaller, PAT.Entities.PatConfiguracionTallerKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, PAT.Entities.PatConfiguracionTallerKey key)
		{
			return Delete(transactionManager, key.IdTaller);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="_idTaller">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Int32 _idTaller)
		{
			return Delete(null, _idTaller);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idTaller">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Int32 _idTaller);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO key.
		///		FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO Description: 
		/// </summary>
		/// <param name="_idEmpleadoEncargado"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatConfiguracionTaller objects.</returns>
		public TList<PatConfiguracionTaller> GetByIdEmpleadoEncargado(System.Int32 _idEmpleadoEncargado)
		{
			int count = -1;
			return GetByIdEmpleadoEncargado(_idEmpleadoEncargado, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO key.
		///		FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idEmpleadoEncargado"></param>
		/// <returns>Returns a typed collection of PAT.Entities.PatConfiguracionTaller objects.</returns>
		/// <remarks></remarks>
		public TList<PatConfiguracionTaller> GetByIdEmpleadoEncargado(TransactionManager transactionManager, System.Int32 _idEmpleadoEncargado)
		{
			int count = -1;
			return GetByIdEmpleadoEncargado(transactionManager, _idEmpleadoEncargado, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO key.
		///		FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idEmpleadoEncargado"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatConfiguracionTaller objects.</returns>
		public TList<PatConfiguracionTaller> GetByIdEmpleadoEncargado(TransactionManager transactionManager, System.Int32 _idEmpleadoEncargado, int start, int pageLength)
		{
			int count = -1;
			return GetByIdEmpleadoEncargado(transactionManager, _idEmpleadoEncargado, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO key.
		///		fkPatConfiguracionTallerPatEmpleado Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idEmpleadoEncargado"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatConfiguracionTaller objects.</returns>
		public TList<PatConfiguracionTaller> GetByIdEmpleadoEncargado(System.Int32 _idEmpleadoEncargado, int start, int pageLength)
		{
			int count =  -1;
			return GetByIdEmpleadoEncargado(null, _idEmpleadoEncargado, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO key.
		///		fkPatConfiguracionTallerPatEmpleado Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="_idEmpleadoEncargado"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of PAT.Entities.PatConfiguracionTaller objects.</returns>
		public TList<PatConfiguracionTaller> GetByIdEmpleadoEncargado(System.Int32 _idEmpleadoEncargado, int start, int pageLength,out int count)
		{
			return GetByIdEmpleadoEncargado(null, _idEmpleadoEncargado, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO key.
		///		FK_PAT_CONFIGURACION_TALLER_PAT_EMPLEADO Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idEmpleadoEncargado"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of PAT.Entities.PatConfiguracionTaller objects.</returns>
		public abstract TList<PatConfiguracionTaller> GetByIdEmpleadoEncargado(TransactionManager transactionManager, System.Int32 _idEmpleadoEncargado, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override PAT.Entities.PatConfiguracionTaller Get(TransactionManager transactionManager, PAT.Entities.PatConfiguracionTallerKey key, int start, int pageLength)
		{
			return GetByIdTaller(transactionManager, key.IdTaller, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_PAT_CONFIGURACION_TALLER index.
		/// </summary>
		/// <param name="_idTaller"></param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatConfiguracionTaller"/> class.</returns>
		public PAT.Entities.PatConfiguracionTaller GetByIdTaller(System.Int32 _idTaller)
		{
			int count = -1;
			return GetByIdTaller(null,_idTaller, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_CONFIGURACION_TALLER index.
		/// </summary>
		/// <param name="_idTaller"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatConfiguracionTaller"/> class.</returns>
		public PAT.Entities.PatConfiguracionTaller GetByIdTaller(System.Int32 _idTaller, int start, int pageLength)
		{
			int count = -1;
			return GetByIdTaller(null, _idTaller, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_CONFIGURACION_TALLER index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idTaller"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatConfiguracionTaller"/> class.</returns>
		public PAT.Entities.PatConfiguracionTaller GetByIdTaller(TransactionManager transactionManager, System.Int32 _idTaller)
		{
			int count = -1;
			return GetByIdTaller(transactionManager, _idTaller, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_CONFIGURACION_TALLER index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idTaller"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatConfiguracionTaller"/> class.</returns>
		public PAT.Entities.PatConfiguracionTaller GetByIdTaller(TransactionManager transactionManager, System.Int32 _idTaller, int start, int pageLength)
		{
			int count = -1;
			return GetByIdTaller(transactionManager, _idTaller, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_CONFIGURACION_TALLER index.
		/// </summary>
		/// <param name="_idTaller"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatConfiguracionTaller"/> class.</returns>
		public PAT.Entities.PatConfiguracionTaller GetByIdTaller(System.Int32 _idTaller, int start, int pageLength, out int count)
		{
			return GetByIdTaller(null, _idTaller, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_PAT_CONFIGURACION_TALLER index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="_idTaller"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="PAT.Entities.PatConfiguracionTaller"/> class.</returns>
		public abstract PAT.Entities.PatConfiguracionTaller GetByIdTaller(TransactionManager transactionManager, System.Int32 _idTaller, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a TList&lt;PatConfiguracionTaller&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="TList&lt;PatConfiguracionTaller&gt;"/></returns>
		public static TList<PatConfiguracionTaller> Fill(IDataReader reader, TList<PatConfiguracionTaller> rows, int start, int pageLength)
		{
			NetTiersProvider currentProvider = DataRepository.Provider;
            bool useEntityFactory = currentProvider.UseEntityFactory;
            bool enableEntityTracking = currentProvider.EnableEntityTracking;
            LoadPolicy currentLoadPolicy = currentProvider.CurrentLoadPolicy;
			Type entityCreationFactoryType = currentProvider.EntityCreationalFactoryType;
			
			// advance to the starting row
			for (int i = 0; i < start; i++)
			{
				if (!reader.Read())
				return rows; // not enough rows, just return
			}
			for (int i = 0; i < pageLength; i++)
			{
				if (!reader.Read())
					break; // we are done
					
				string key = null;
				
				PAT.Entities.PatConfiguracionTaller c = null;
				if (useEntityFactory)
				{
					key = new System.Text.StringBuilder("PatConfiguracionTaller")
					.Append("|").Append((System.Int32)reader[((int)PatConfiguracionTallerColumn.IdTaller - 1)]).ToString();
					c = EntityManager.LocateOrCreate<PatConfiguracionTaller>(
					key.ToString(), // EntityTrackingKey
					"PatConfiguracionTaller",  //Creational Type
					entityCreationFactoryType,  //Factory used to create entity
					enableEntityTracking); // Track this entity?
				}
				else
				{
					c = new PAT.Entities.PatConfiguracionTaller();
				}
				
				if (!enableEntityTracking ||
					c.EntityState == EntityState.Added ||
					(enableEntityTracking &&
					
						(
							(currentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
							(currentLoadPolicy == LoadPolicy.DiscardChanges && c.EntityState != EntityState.Unchanged)
						)
					))
				{
					c.SuppressEntityEvents = true;
					c.IdTaller = (System.Int32)reader[((int)PatConfiguracionTallerColumn.IdTaller - 1)];
					c.OriginalIdTaller = c.IdTaller;
					c.CargoEncargadoTaller = (System.String)reader[((int)PatConfiguracionTallerColumn.CargoEncargadoTaller - 1)];
					c.IdEmpleadoEncargado = (System.Int32)reader[((int)PatConfiguracionTallerColumn.IdEmpleadoEncargado - 1)];
					c.HoraInicioRecepcion = (System.DateTime)reader[((int)PatConfiguracionTallerColumn.HoraInicioRecepcion - 1)];
					c.HoraFinalizacionRecepcion = (System.DateTime)reader[((int)PatConfiguracionTallerColumn.HoraFinalizacionRecepcion - 1)];
					c.HoraInicioMecanicos = (System.DateTime)reader[((int)PatConfiguracionTallerColumn.HoraInicioMecanicos - 1)];
					c.HoraFinalizacinMecanicos = (System.DateTime)reader[((int)PatConfiguracionTallerColumn.HoraFinalizacinMecanicos - 1)];
					c.CantidadCitasXHora = (System.Byte)reader[((int)PatConfiguracionTallerColumn.CantidadCitasXHora - 1)];
					c.ModificarMecanicoOt = (System.Boolean)reader[((int)PatConfiguracionTallerColumn.ModificarMecanicoOt - 1)];
					c.ModificarTiempoOt = (System.Boolean)reader[((int)PatConfiguracionTallerColumn.ModificarTiempoOt - 1)];
					c.MaximoOtsXMecanico = (System.Byte)reader[((int)PatConfiguracionTallerColumn.MaximoOtsXMecanico - 1)];
					c.EntityTrackingKey = key;
					c.AcceptChanges();
					c.SuppressEntityEvents = false;
				}
				rows.Add(c);
			}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatConfiguracionTaller"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatConfiguracionTaller"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, PAT.Entities.PatConfiguracionTaller entity)
		{
			if (!reader.Read()) return;
			
			entity.IdTaller = (System.Int32)reader[((int)PatConfiguracionTallerColumn.IdTaller - 1)];
			entity.OriginalIdTaller = (System.Int32)reader["ID_TALLER"];
			entity.CargoEncargadoTaller = (System.String)reader[((int)PatConfiguracionTallerColumn.CargoEncargadoTaller - 1)];
			entity.IdEmpleadoEncargado = (System.Int32)reader[((int)PatConfiguracionTallerColumn.IdEmpleadoEncargado - 1)];
			entity.HoraInicioRecepcion = (System.DateTime)reader[((int)PatConfiguracionTallerColumn.HoraInicioRecepcion - 1)];
			entity.HoraFinalizacionRecepcion = (System.DateTime)reader[((int)PatConfiguracionTallerColumn.HoraFinalizacionRecepcion - 1)];
			entity.HoraInicioMecanicos = (System.DateTime)reader[((int)PatConfiguracionTallerColumn.HoraInicioMecanicos - 1)];
			entity.HoraFinalizacinMecanicos = (System.DateTime)reader[((int)PatConfiguracionTallerColumn.HoraFinalizacinMecanicos - 1)];
			entity.CantidadCitasXHora = (System.Byte)reader[((int)PatConfiguracionTallerColumn.CantidadCitasXHora - 1)];
			entity.ModificarMecanicoOt = (System.Boolean)reader[((int)PatConfiguracionTallerColumn.ModificarMecanicoOt - 1)];
			entity.ModificarTiempoOt = (System.Boolean)reader[((int)PatConfiguracionTallerColumn.ModificarTiempoOt - 1)];
			entity.MaximoOtsXMecanico = (System.Byte)reader[((int)PatConfiguracionTallerColumn.MaximoOtsXMecanico - 1)];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="PAT.Entities.PatConfiguracionTaller"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatConfiguracionTaller"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, PAT.Entities.PatConfiguracionTaller entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IdTaller = (System.Int32)dataRow["ID_TALLER"];
			entity.OriginalIdTaller = (System.Int32)dataRow["ID_TALLER"];
			entity.CargoEncargadoTaller = (System.String)dataRow["CARGO_ENCARGADO_TALLER"];
			entity.IdEmpleadoEncargado = (System.Int32)dataRow["ID_EMPLEADO_ENCARGADO"];
			entity.HoraInicioRecepcion = (System.DateTime)dataRow["HORA_INICIO_RECEPCION"];
			entity.HoraFinalizacionRecepcion = (System.DateTime)dataRow["HORA_FINALIZACION_RECEPCION"];
			entity.HoraInicioMecanicos = (System.DateTime)dataRow["HORA_INICIO_MECANICOS"];
			entity.HoraFinalizacinMecanicos = (System.DateTime)dataRow["HORA_FINALIZACIN_MECANICOS"];
			entity.CantidadCitasXHora = (System.Byte)dataRow["CANTIDAD_CITAS_X_HORA"];
			entity.ModificarMecanicoOt = (System.Boolean)dataRow["MODIFICAR_MECANICO_OT"];
			entity.ModificarTiempoOt = (System.Boolean)dataRow["MODIFICAR_TIEMPO_OT"];
			entity.MaximoOtsXMecanico = (System.Byte)dataRow["MAXIMO_OTS_X_MECANICO"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="PAT.Entities.PatConfiguracionTaller"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">PAT.Entities.PatConfiguracionTaller Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		public override void DeepLoad(TransactionManager transactionManager, PAT.Entities.PatConfiguracionTaller entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region IdEmpleadoEncargadoSource	
			if (CanDeepLoad(entity, "PatEmpleado|IdEmpleadoEncargadoSource", deepLoadType, innerList) 
				&& entity.IdEmpleadoEncargadoSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IdEmpleadoEncargado;
				PatEmpleado tmpEntity = EntityManager.LocateEntity<PatEmpleado>(EntityLocator.ConstructKeyFromPkItems(typeof(PatEmpleado), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IdEmpleadoEncargadoSource = tmpEntity;
				else
					entity.IdEmpleadoEncargadoSource = DataRepository.PatEmpleadoProvider.GetByIdEmpleado(transactionManager, entity.IdEmpleadoEncargado);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdEmpleadoEncargadoSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdEmpleadoEncargadoSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PatEmpleadoProvider.DeepLoad(transactionManager, entity.IdEmpleadoEncargadoSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IdEmpleadoEncargadoSource

			#region IdTallerSource	
			if (CanDeepLoad(entity, "PatTaller|IdTallerSource", deepLoadType, innerList) 
				&& entity.IdTallerSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IdTaller;
				PatTaller tmpEntity = EntityManager.LocateEntity<PatTaller>(EntityLocator.ConstructKeyFromPkItems(typeof(PatTaller), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IdTallerSource = tmpEntity;
				else
					entity.IdTallerSource = DataRepository.PatTallerProvider.GetByIdTaller(transactionManager, entity.IdTaller);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IdTallerSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IdTallerSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.PatTallerProvider.DeepLoad(transactionManager, entity.IdTallerSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IdTallerSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the PAT.Entities.PatConfiguracionTaller object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">PAT.Entities.PatConfiguracionTaller instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">PAT.Entities.PatConfiguracionTaller Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		public override bool DeepSave(TransactionManager transactionManager, PAT.Entities.PatConfiguracionTaller entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region IdEmpleadoEncargadoSource
			if (CanDeepSave(entity, "PatEmpleado|IdEmpleadoEncargadoSource", deepSaveType, innerList) 
				&& entity.IdEmpleadoEncargadoSource != null)
			{
				DataRepository.PatEmpleadoProvider.Save(transactionManager, entity.IdEmpleadoEncargadoSource);
				entity.IdEmpleadoEncargado = entity.IdEmpleadoEncargadoSource.IdEmpleado;
			}
			#endregion 
			
			#region IdTallerSource
			if (CanDeepSave(entity, "PatTaller|IdTallerSource", deepSaveType, innerList) 
				&& entity.IdTallerSource != null)
			{
				DataRepository.PatTallerProvider.Save(transactionManager, entity.IdTallerSource);
				entity.IdTaller = entity.IdTallerSource.IdTaller;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region PatConfiguracionTallerChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>PAT.Entities.PatConfiguracionTaller</c>
	///</summary>
	public enum PatConfiguracionTallerChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>PatEmpleado</c> at IdEmpleadoEncargadoSource
		///</summary>
		[ChildEntityType(typeof(PatEmpleado))]
		PatEmpleado,
			
		///<summary>
		/// Composite Property for <c>PatTaller</c> at IdTallerSource
		///</summary>
		[ChildEntityType(typeof(PatTaller))]
		PatTaller,
		}
	
	#endregion PatConfiguracionTallerChildEntityTypes
	
	#region PatConfiguracionTallerFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;PatConfiguracionTallerColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatConfiguracionTaller"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatConfiguracionTallerFilterBuilder : SqlFilterBuilder<PatConfiguracionTallerColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatConfiguracionTallerFilterBuilder class.
		/// </summary>
		public PatConfiguracionTallerFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatConfiguracionTallerFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatConfiguracionTallerFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatConfiguracionTallerFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatConfiguracionTallerFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatConfiguracionTallerFilterBuilder
	
	#region PatConfiguracionTallerParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;PatConfiguracionTallerColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatConfiguracionTaller"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class PatConfiguracionTallerParameterBuilder : ParameterizedSqlFilterBuilder<PatConfiguracionTallerColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatConfiguracionTallerParameterBuilder class.
		/// </summary>
		public PatConfiguracionTallerParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the PatConfiguracionTallerParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public PatConfiguracionTallerParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the PatConfiguracionTallerParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public PatConfiguracionTallerParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion PatConfiguracionTallerParameterBuilder
	
	#region PatConfiguracionTallerSortBuilder
    
    /// <summary>
    /// A strongly-typed instance of the <see cref="SqlSortBuilder&lt;PatConfiguracionTallerColumn&gt;"/> class
	/// that is used exclusively with a <see cref="PatConfiguracionTaller"/> object.
    /// </summary>
    [CLSCompliant(true)]
    public class PatConfiguracionTallerSortBuilder : SqlSortBuilder<PatConfiguracionTallerColumn>
    {
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the PatConfiguracionTallerSqlSortBuilder class.
		/// </summary>
		public PatConfiguracionTallerSortBuilder() : base() { }

		#endregion Constructors

    }    
    #endregion PatConfiguracionTallerSortBuilder
	
} // end namespace
